{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_zakharov:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Zakharov\n",
    "\n",
    "The Zakharov function has no local minima except the global one. It is shown here in its two-dimensional form."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Definition**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\\begin{align}\n",
    "\\begin{split}\n",
    "f(x) &=& \\sum\\limits_{i=1}^n {x_i^2} + \\bigg( \\frac{1}{2} \\sum\\limits_{i=1}^n {ix_i} \\bigg)^2 + \\bigg( \\frac{1}{2} \\sum\\limits_{i=1}^n {ix_i} \\bigg)^4, \\\\[2mm]\n",
    "&& -10 \\leq x_i \\leq 10 \\quad i=1,\\ldots,n\n",
    "\\end{split}\n",
    "\\end{align}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Optimum**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$f(x^*) = 0 \\; \\text{at} \\; x^* = (0,\\ldots,0) $$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Fitness Landscape**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "from pymoo.problems import get_problem\n",
    "from pymoo.visualization.fitness_landscape import FitnessLandscape\n",
    "\n",
    "problem = get_problem(\"zakharov\", n_var=2)\n",
    "\n",
    "FitnessLandscape(problem, angle=(45, 45), _type=\"surface\").show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "FitnessLandscape(problem, _type=\"contour\", contour_levels = 200, colorbar=True).show()"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
